package com.niuxiaofa.newlaw.Network;

import com.niuxiaofa.newlaw.Bean.BaseBean;
import com.niuxiaofa.newlaw.Bean.NewOrderBean;
import com.niuxiaofa.newlaw.Bean.VideoListBean;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class PublicPresenter {

    /**
     *
     */
    public static void newOrder(interface_newOrder interface_newOrder) {
        Call<NewOrderBean> call = ServiceManager.getInstance().creat(ApiService.class).newOrder();
        call.enqueue(new Callback<NewOrderBean>() {
            @Override
            public void onResponse(Call<NewOrderBean> call, Response<NewOrderBean> response) {
                //判断请求是否成功
                if (response.isSuccessful()) {
                    NewOrderBean bean = (NewOrderBean) response.body();
                    interface_newOrder.getResponse(bean);
                }
            }

            @Override
            public void onFailure(Call<NewOrderBean> call, Throwable t) {
//            Log.e("链接错误", t.getMessage());

            }
        });

    }

    public interface interface_newOrder {
        void getResponse(NewOrderBean u);
    }


    public static void getVideoList(int current,interface_getVideoList interface_getVideoList) {

        Call<VideoListBean> call = ServiceManager.getInstance().creat(ApiService.class).getVideoList(current,3);
        call.enqueue(new Callback<VideoListBean>() {
            @Override
            public void onResponse(Call<VideoListBean> call, Response<VideoListBean> response) {
                //判断请求是否成功
                if (response.isSuccessful()) {
                    VideoListBean bean = (VideoListBean) response.body();
                    interface_getVideoList.getResponse(bean);
                }
            }

            @Override
            public void onFailure(Call<VideoListBean> call, Throwable t) {
//            Log.e("链接错误", t.getMessage());

            }
        });

    }

    public interface interface_getVideoList{
        void getResponse(VideoListBean u);
    }


    public static void getUploadSignature(interface_getUploadSignature interface_getUploadSignature) {

        Call<BaseBean> call = ServiceManager.getInstance().creat(ApiService.class).getUploadSignature();
        call.enqueue(new Callback<BaseBean>() {
            @Override
            public void onResponse(Call<BaseBean> call, Response<BaseBean> response) {
                //判断请求是否成功
                if (response.isSuccessful()) {
                    BaseBean bean = (BaseBean) response.body();
                    interface_getUploadSignature.getResponse(bean);
                }
            }

            @Override
            public void onFailure(Call<BaseBean> call, Throwable t) {
//            Log.e("链接错误", t.getMessage());

            }
        });

    }

    public interface interface_getUploadSignature{
        void getResponse(BaseBean u);
    }

}
